package thread;

public class Demo9 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
           for(int i = 0; i < 5;i++) {
               System.out.println(Thread.currentThread().getName() + "存活");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        });

        System.out.println(Thread.currentThread().getName() + "ID" + t.getId());
        System.out.println(Thread.currentThread().getName() + "状态" + t.getState());
        System.out.println(Thread.currentThread().getName() + "名字" + t.getName());
        System.out.println(Thread.currentThread().getName() + "优先级" + t.getPriority());
        t.start();

        while(t.isAlive()) {
            System.out.println(Thread.currentThread().getName() + "状态" + t.getState());
        }
    }

    public static void main1(String[] args) {
        Thread t = new Thread(() -> {
            System.out.println(Thread.currentThread().getName());
        });

        //不能进行二次start进入线程
        t.start();
//        t.start();
    }
}
